package com.jyw.business.ins.wechat.controller;

import com.jyw.business.ast.domain.dto.wechat.WechatInsRecordAstPageDto;
import com.jyw.business.ast.domain.vo.web.InsRecordAstPageVo;
import com.jyw.business.ins.domain.dto.wechat.WechatRecordUnitPageDto;
import com.jyw.business.ins.domain.vo.web.RecordDetailVo;
import com.jyw.business.ins.domain.vo.web.RecordUnitPageVo;
import com.jyw.business.ins.service.IInsTaskService;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.page.BasePage;
import com.jyw.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 巡检配置项Controller
 * 
 * @author system
 * @date 2023-09-20
 */
@RestController
@RequestMapping("/wechat/ins/record")
@Api(tags = "巡检记录")
public class WechatInsRecordController extends BaseController
{
    @Resource
    private IInsTaskService taskService;

    /**
     * 资产查询
     */
    @PreAuthorize("@ss.hasPermi('ins:record:list')")
    @PostMapping("/ast/list")
    @ApiOperation("资产查询")
    public TableDataInfo<InsRecordAstPageVo> astList(BasePage page,@RequestBody WechatInsRecordAstPageDto dto)
    {
        if(!ObjectUtils.isEmpty(page)){
            startPage();
        }
        List<InsRecordAstPageVo> list = taskService.wxRecordAstList(dto);
        return getDataTable(list);
    }

    /**
     * 巡检单元查询
     */
    @PreAuthorize("@ss.hasPermi('ins:record:list')")
    @PostMapping("/unit/list")
    @ApiOperation("巡检单元查询")
    public TableDataInfo<RecordUnitPageVo> unitList(BasePage page, @RequestBody WechatRecordUnitPageDto dto)
    {
        if(!ObjectUtils.isEmpty(page)){
            startPage();
        }
        List<RecordUnitPageVo> list = taskService.wxRecordUnitList(dto);
        return getDataTable(list);
    }

    /**
     * 巡检单元查询
     */
    @PreAuthorize("@ss.hasPermi('ins:record:detail')")
    @GetMapping("/{id}")
    @ApiOperation("巡检记录详情查询")
    public CommonResult<RecordDetailVo> detail(@PathVariable("id")Long id)
    {
        RecordDetailVo detail = taskService.detail(id);
        return CommonResult.success(detail);
    }


}
